package com.lad.provider.controller;

import com.google.gson.Gson;
import com.lad.provider.logAspect.WebLog;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class HelloController {

    private final static Logger log = LoggerFactory.getLogger(HelloController.class);

   //@CrossOrigin(value = "http://localhost:8081")
    @GetMapping("/hello")
    @WebLog(description = "hello get()接收到请求")
    public String hello(@RequestParam String type) {
        log.info("接收到type:" + type);
        return new Gson().toJson("hello -- " + type);
    }

   // @CrossOrigin(value = "http://localhost:8081")
    @PostMapping("/hello")
    @WebLog(description = "hello post()接收到请求")
    public String hello2(@RequestParam String type) {
        log.info("接收到type:" + type);
        return new Gson().toJson("hello -- " + type);
    }

}